package edu.its.dreamteam.web.components;

import org.apache.tapestry.Asset;
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.annotations.Path;
import org.apache.tapestry.ioc.annotations.Inject;

import edu.its.dreamteam.daf.beans.Manager;
import edu.its.dreamteam.daf.dao.IManagerDao;
import edu.its.dreamteam.web.base.SecureBasePage;

public class Layout extends SecureBasePage {
	
	@Inject
	@Path("context:css/style.css")
	private Asset style;
	
	@Inject
	@Path("context:js/dojo-1.0.2/dojo/resources/dojo.css")
	private Asset dojo;
	
	@Inject
	@Path("context:js/dojo-1.0.2/dijit/themes/soria/soria.css")
	private Asset theme;
	
	@Inject
	@Path("context:js/dojo-1.0.2/dojo/dojo.js")
	private Asset theDojoScript;
	
	@Inject
	private IManagerDao managerDao;
	
	private boolean login;
	private boolean administrator;
	
	public boolean isLogin() {
		return login;
	}
	public void setLogin(boolean login) {
		this.login = login;
	}
	
	public boolean isAdministrator() {
		Manager manager = (Manager)getManagerDao().findByPrimaryKey(getVisit().getUsername());
		if(manager.getStatus().equals("1")){
			administrator = true;
		}else{
			administrator = false;
		}
		return administrator;
	}
	
	
	public IManagerDao getManagerDao() {
		return managerDao;
	}
	public Asset getStyle() { 
		return style; 
	}
		
	public Asset getDojo() {
		return dojo;
	}
	
	
	public Asset getTheme() {
		return theme;
	}
	public Asset getTheDojoScript() {
		return theDojoScript;
	}
	boolean beforeRender(MarkupWriter writer){
		 return true;
	}
}
